﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace _02windowCalculator
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {

        }

        private void button1_Click(object sender, EventArgs e)
        {
            double a= 0, b = 0;
            if(textBox1.Text != "")
                a = double.Parse(textBox1.Text);
            if (textBox3.Text != "")
                b = double.Parse(textBox3.Text);
            double ans;

            if (textBox3.Text != "")
            {
                string c = this.comboBox1.Text;
                char[] ch = c.ToCharArray();
                switch (ch[0])
                {
                    case '+':
                        ans = a + b;
                        this.label1.Text = a + "+" + b + "=" + ans;
                        break;
                    case '-':
                        ans = a - b;
                        this.label1.Text = a + "-" + b + "=" + ans;
                        break;
                    case '*':
                        ans = a * b;
                        this.label1.Text = a + "*" + b + "=" + ans;
                        break;
                    case '/':
                        ans = a / b;
                        this.label1.Text = a + "/" + b + "=" + ans;
                        break;
                    default:
                        this.label1.Text = "请输入正确的数字或选择正确的操作符！";
                        break;

                }

            }
        }

    }
}
